package shuashuami.hb.com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import shuashuami.hb.com.hbclient.R;
import shuashuami.hb.com.manager.HbAppManager;
import shuashuami.hb.com.model.Complaint;

/**
 * Created by Administrator on 2017/6/20.
 */

public class ComplaintListAdatper extends BaseAdapter {
    private LayoutInflater inflater;
    private List<Complaint> list;
    private Context con;


    public ComplaintListAdatper(List<Complaint> list, Context context) {
        this.con = context;
        inflater = LayoutInflater.from(context);
        this.list = list;
    }

    @Override
    public int getCount() {
        if (null != list) {
            return list.size();
        } else {
            return 0;
        }
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        TaskViewHoler viewHolder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.adapter_complaint_list, null);
            viewHolder = new TaskViewHoler();
            viewHolder.tvId = (TextView) convertView.findViewById(R.id.tv_complaint_id);
            viewHolder.tvStatus = (TextView) convertView.findViewById(R.id.tv_complaint_status);
            viewHolder.tvMessage = (TextView) convertView.findViewById(R.id.tv_complaint_message);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (TaskViewHoler) convertView.getTag();
        }
        final Complaint content = list.get(position);
        int tag = HbAppManager.getInstance().getTypeValue();
        if (tag == 1) {
            viewHolder.tvId.setText("商家ID：" + content.getId());
        } else {
            viewHolder.tvId.setText("刷手ID：" + content.getId());
        }

        viewHolder.tvStatus.setText(content.getStatus());
        viewHolder.tvMessage.setText(content.getMesssage());
        return convertView;
    }

    class TaskViewHoler {
        public TextView tvId, tvStatus, tvMessage;
    }


}





